package com.qf.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @Description: 公用常量
 * @Data: 2022/9/6 9:57
 * @Pacakge: com.qf.controller
 * @ClassName: FileUpLoad
 * @Author: fan
 */
@Controller
@RequestMapping("upload")
public class FileUpLoad {
    @RequestMapping(value = "fileUpLOad",method = RequestMethod.POST)
    public String fileUpLoad(MultipartFile upload) throws IOException {
        System.out.println("springmvc文件上传方式");
        System.out.println("upload="+upload);
        //要上传的文件目录
        String path = "D:\\aa";
        //获取文件上传名称
        String filename = upload.getOriginalFilename();
        //完成文件上传
        upload.transferTo(new File(path,filename));
        return "success";
    }
}
